using System;
using System.Collections.Generic;
using UnityEngine;
using QFramework;
using UnityEngine.UI;

namespace ProjectMyFarmAndShe
{
	public partial class DialogPanel : ViewController
	{
		private List<DialogData> mData;
		private int mIndex = 0;

		void Start()
		{
			// Code Here
			OperationItemTemplate.Hide();
		}

		public void SetDialogData(List<DialogData> data)
		{
			mData = data;
			mIndex = 0;

			UpdateDialog();
		}

		void UpdateDialog()
		{
			var data = mData[mIndex];

			ContentText.text = data.Content;
			Root.DestroyChildren();
			
			foreach (var operationData in data.OperationDatas)
			{
				OperationItemTemplate.InstantiateWithParent(Root)
					.Self(self =>
					{
						self.Init(operationData);
					})
					.Show();
			}
		}
	}
}
